package org.cbg.panel;

import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;

import javax.swing.JPanel;

import org.cbg.bean.SearchOrderBean;
import org.cbg.btn.TrslationBtn;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.CutButtonImage;
import org.come.until.GsonUtil;

 

/*
 * 我的藏宝阁面板
 */

public class TraslationMyMainJpanel extends JPanel {
    /**
     * 我的订单，指定购买，我的货物
     */
    private TrslationBtn myorder, zhidinggoumai, mygoods;

    /**
     * 卡片面板
     */
    private TraslationMyMainCardJpanel traslationMyMainCardJpanel;

    public TraslationMyMainJpanel() {
        this.setPreferredSize(new Dimension(760, 460));
        this.setLayout(null);
        this.setOpaque(false);


        traslationMyMainCardJpanel = new TraslationMyMainCardJpanel();
        this.add(traslationMyMainCardJpanel);
        myorder = new TrslationBtn("inkImg/number/b4/W01.png", 1);
        zhidinggoumai = new TrslationBtn("inkImg/number/b4/W02a.png", 1);
        mygoods = new TrslationBtn("inkImg/number/b4/W03a.png", 1);

        myorder.setBounds(5, 2, 102, 31);
        zhidinggoumai.setBounds(5+103, 2, 83, 31);
        mygoods.setBounds(5+103+83, 2, 103, 31);

        this.add(myorder);
        this.add(zhidinggoumai);
        this.add(mygoods);
        mygoods.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                // TODO Auto-generated method stub

                try {
                    myorder.setIcons(CutButtonImage.cuts("inkImg/number/b4/W01a.png"));
                    zhidinggoumai.setIcons(CutButtonImage.cuts("inkImg/number/b4/W02a.png"));
                    mygoods.setIcons(CutButtonImage.cuts("inkImg/number/b4/W03.png"));
                } catch (Exception e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
                /**
                 * 传递数据获取我的藏宝阁我的货物中的数据信息 1、获取当前页数(点击我的货物按钮页数默认为1)
                 * 2、转换为对应协议的json对象 3、发送给服务器处理数据信息
                 */
                String sendmes = Agreement.getAgreement().searchMyGoodsAgreement(1 + "");
                SendMessageUntil.toServer(sendmes);

            }
        });
        zhidinggoumai.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                // TODO Auto-generated method stub
                try {
                    myorder.setIcons(CutButtonImage.cuts("inkImg/number/b4/W01a.png"));
                    zhidinggoumai.setIcons(CutButtonImage.cuts("inkImg/number/b4/W02.png"));
                    mygoods.setIcons(CutButtonImage.cuts("inkImg/number/b4/W03a.png"));
                } catch (Exception e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
                /**
                 * 传递数据获取我的藏宝阁指定购买中的数据信息 1、获取角色ID 2、获取当前页数(点击我的货物按钮页数默认为1)
                 * 3、转换为对应协议的json对象 4、发送给服务器处理数据信息
                 */
                String sendmes = Agreement.getAgreement().searchAppointAgreement(1 + "");
                SendMessageUntil.toServer(sendmes);

                // traslationMyMainCardJpanel.getCardLayout().show(traslationMyMainCardJpanel,
                // "zhidinggoumai");
            }
        });
        myorder.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                try {
                    myorder.setIcons(CutButtonImage.cuts("inkImg/number/b4/W01.png"));
                    zhidinggoumai.setIcons(CutButtonImage.cuts("inkImg/number/b4/W02a.png"));
                    mygoods.setIcons(CutButtonImage.cuts("inkImg/number/b4/W03a.png"));
                } catch (Exception e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
                /**
                 * 传递数据获取我的藏宝阁指定购买中的数据信息 1、初始化SearchOrderBean对象
                 * 2、SearchOrderBean对象获取角色ID 3、SearchOrderBean对象获取订单状态(1未付钱 ，2超时
                 * ， 3已付钱 ，4已取货 5、所有订单) 4、SearchOrderBean对象获取查询时间(1、一周内 2、一个月内
                 * 3、一个月前) 5、SearchOrderBean对象获取当前页数(点击我的订单按钮页数默认为1)
                 * 6、SearchOrderBean对象转换为对应协议的json对象 7、发送给服务器处理数据信息
                 */

                SearchOrderBean searchOrderBean = new SearchOrderBean();
                searchOrderBean.setTime(1);
                searchOrderBean.setPageNum(1);
                String sendmes = Agreement.getAgreement().searchMyOrderAgreement(
                        GsonUtil.getGsonUtil().getgson().toJson(searchOrderBean));
                SendMessageUntil.toServer(sendmes);
                /**
                 * 展示我的订单面板
                 */
                // traslationMyMainCardJpanel.getCardLayout().show(traslationMyMainCardJpanel,
                // "myorder");
            }
        });

    }

    public TrslationBtn getMyorder() {
        return myorder;
    }

    public void setMyorder(TrslationBtn myorder) {
        this.myorder = myorder;
    }

    public TrslationBtn getZhidinggoumai() {
        return zhidinggoumai;
    }

    public void setZhidinggoumai(TrslationBtn zhidinggoumai) {
        this.zhidinggoumai = zhidinggoumai;
    }

    public TrslationBtn getMygoods() {
        return mygoods;
    }

    public void setMygoods(TrslationBtn mygoods) {
        this.mygoods = mygoods;
    }

    public TraslationMyMainCardJpanel getTraslationMyMainCardJpanel() {
        return traslationMyMainCardJpanel;
    }

    public void setTraslationMyMainCardJpanel(TraslationMyMainCardJpanel traslationMyMainCardJpanel) {
        this.traslationMyMainCardJpanel = traslationMyMainCardJpanel;
    }

}
